<%@ page import="java.io.File" %>
<%@ page import="com.utils.failureanalysis.data.model.singleRecorder.AnalysisData" %>
<%--
  Created by IntelliJ IDEA.
  User: zhuwh4
  Date: 2018/7/5
  Time: 17:17
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <%--<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>--%>
    <title>Failure Details Page</title>
    <style>
        span {
            color: red
        }
    </style>
</head>
<body>
<%
    String baseFile = "D:\\jenkins\\video";
    File file = new File(baseFile);
    String[] filePath = file.list();
%>

<form action="../save">
    <input type="hidden" name="id" value="${analysisData.id}"/>
    <input type="hidden" name="taskId" value="${analysisData.taskId}"/>
    <input type="hidden" name="date" value="${analysisData.date}"/>
    <input type="hidden" name="moduleName" value="${analysisData.moduleName}"/>
    <input type="hidden" name="caseName" value="${analysisData.caseName}"/>
    <input type="hidden" name="details" value="${analysisData.details}"/>
    <input type="hidden" name="stackTrace" value="${analysisData.stackTrace}"/>
    <input type="hidden" name="passOrFail" value="${analysisData.passOrFail}"/>
    <table id="details" border="1">
        <tr>
            <td>${analysisData.moduleName}</td>
            <td>${analysisData.date}</td>
            <td>${analysisData.caseName}</td>
            <td>${analysisData.details}</td>
            <td>${analysisData.stackTrace}</td>
            <td onselectstart="return false;" onclick="modifyValue(this)">是否修改：<span>Y</span></td>
        </tr>
    </table>
    <input type="hidden" name="modify" value="true">
    <textarea name="rootCause" id="analysis" cols="30" rows="10" onfocus="if(value=='原因分析')value=''"
              onblur="if(value=='')value='原因分析'">${analysisData.rootCause}</textarea>
    <textarea name="solution" id="resolveMethod" cols="30" rows="10" onfocus="if(value=='解决思路')value=''"
              onblur="if(value=='')value='解决思路'">${analysisData.solution}</textarea>
    <div>
        <button onclick="location.href='/data'">取消</button>
        <button>提交</button>
    </div>
</form>

<div>
    <video id="showedVideo" src="D:\jenkins\video\0709115857.mp4" controls="controls">视频</video>
    <%--<video id="showedVideo" src="" controls="controls">视频</video>--%>
</div>

<div>
</div>
<div>
    <input type="button" name="lastVideo" value="查看上一个视频" onclick="showNextVideo()"/>
    <input type="button" name="exploreVideoList" value="浏览..."/>
    <select id="selector" onchange="selectVideo()">
        <%
            for (String s : filePath) {
        %>
        <option value="<%=file+File.separator+s%>"><%=s%>
        </option>
        <%
            }
        %>
    </select>
    <input type="button" name="nextVideo" value="查看下一个视频" onclick="showLastVideo()"/>
</div>

<script type="text/javascript">
    function showNextVideo() {
        var index = document.getElementById("selector").selectedIndex;
        document.getElementById("selector").options[index - 1].selected = true;
        selectVideo();
    }

    function showLastVideo() {
        var index = document.getElementById("selector").selectedIndex;
        document.getElementById("selector").options[index + 1].selected = true;
        selectVideo();
    }

    function selectVideo() {
        var index = document.getElementById("selector").selectedIndex;
        var videoPath = document.getElementById("selector").options[index].text;
        var basePath = "<%=baseFile.replaceAll("\\\\","\\\\\\\\")%>";
        var filePath = basePath + "\\\\" + videoPath;
        document.getElementById("showedVideo").setAttribute("src", filePath);
    }

    function modifyValue(modifyE) {
        if (modifyE.childNodes[1].firstChild.nodeValue == "Y") {
            modifyE.childNodes[1].firstChild.nodeValue = "N";
            document.getElementsByName("modify").item(0).setAttribute("value","false");
        } else {
            modifyE.childNodes[1].firstChild.nodeValue = "Y";
            document.getElementsByName("modify").item(0).setAttribute("value","true");
        }
    }

    window.onfocus = function () {
        // document.getElementById("analysis").focus();
    }
    window.onload = function () {
    }
</script>
</body>
</html>
